<template>
    <div class="Son">
        <h2>子组件</h2>
        <h3>玩具：{{ toy }}</h3>
        <button @click="emit('send-toy',toy)">把玩具给父组件</button> <!-- 点击按钮触发事件 -->
    </div>
</template>

<script lang="ts" setup name="Son">
    import {ref} from "vue";
    //数据
    let toy = ref("奥特曼")
    //声明接受props
    const emit = defineEmits(['send-toy'])    //调用emit时触发事件
</script>

<style scoped>
.Son{
    background-color: orange;
    width: 1000px;
    height: 200px;
}
</style>